package com.xbongbong.pro.enums.datacenter.datawarning.enums;

import com.xbongbong.i18n.util.I18nMessageUtil;
import lombok.Getter;

import java.util.ArrayList;
import java.util.List;

/**
 * @ClassName RemindStrategyTypeEnum
 * @Description 数据预警提醒策略枚举
 * @Author mengna.Deng
 * @Date 2021/4/15 14:25
 * @Version 1.0
 */
@Getter
public enum DataWarningStrategyTypeEnum {
    /**
     * 执行策略类型枚举
     */
    DAILY(1, "enum.strategyType.memo.daily"),


    WEEKLY(2, "enum.strategyType.memo.weekly"),


    MONTHLY(3, "enum.strategyType.memo.monthly"),


    ANNUALLY(4, "enum.strategyType.memo.annually"),
            ;

    /**
     * 执行策略类型标识值
     */
    private Integer code;
    /**
     * 执行策略类型描述
     */
    private String memo;

    DataWarningStrategyTypeEnum(Integer code, String memo) {
        this.code = code;
        this.memo = memo;
    }

    public static DataWarningStrategyTypeEnum getByCode(Integer code){
        for(DataWarningStrategyTypeEnum remindStrategyTypeEnum: values()){
            if(remindStrategyTypeEnum.getCode().equals(code)){
                return remindStrategyTypeEnum;
            }
        }
        return null;
    }

    /**
     * 获取全部枚举
     *
     * @return List<RemindStrategyTypeEnum>
     */
    public static List<DataWarningStrategyTypeEnum> getAllEnum() {
        List<DataWarningStrategyTypeEnum> list = new ArrayList<>();
        for (DataWarningStrategyTypeEnum cache : values()) {
            list.add(cache);
        }
        return list;
    }

    public String getMemo() {
        return I18nMessageUtil.getMessage(memo);
    }
}
